﻿using Microsoft.AspNetCore.Mvc;
using ShineTech.Web.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ShineTech.Web.Helpers
{
    public abstract class BaseController:ControllerBase
    {
        protected UserDTO GetCurrentUser() 
        {
#if DEBUG
            var userDto = new UserDTO() { Email = "56090120@qq.com", Id = Guid.Parse("fe9dce5c-68b0-4736-b09b-45d30a07dbd1"), Name = "开发账号", Phone = "13333333333" };


#else
            var token = HttpContext.GetToken();
            if (string.IsNullOrWhiteSpace(token))
            {
                return null;
            }
            var userDto = TokenHelper.Token2UserInfo(token);
#endif
            return userDto;
        }

    }
}
